using System.Collections;
using UnityEngine;

public static class UIUtils
{
	public static IEnumerator FadeIn(this CanvasGroup canvasGroup, float speed)
	{
		canvasGroup.alpha = 0f;
		while (canvasGroup.alpha < 1f)
		{
			canvasGroup.alpha += speed * Time.deltaTime;
			yield return null;
		}
		canvasGroup.alpha = 1f;
	}

	public static IEnumerator FadeOut(this CanvasGroup canvasGroup, float speed)
	{
		canvasGroup.alpha = 1f;
		while (canvasGroup.alpha > 0f)
		{
			canvasGroup.alpha -= speed * Time.deltaTime;
			yield return null;
		}
		canvasGroup.alpha = 0f;
	}
}
